package com.ptmall.app.utils;

import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.support.v4.content.FileProvider;


import com.ptmall.app.BuildConfig;

import java.io.File;

/**
 * Created by Administrator on 2017/6/16.
 */

public class UriUtil {

    /**
     * 7.0Uri 机型适配
     * @param context
     * @param file
     * @return
     */
    public static Uri getFileUri(Context context, File file){
        Uri contentUri = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//7.0机型 申请临时访问权限
            contentUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", file);
        } else {
            contentUri = Uri.fromFile(file);
        }
        return contentUri;
    }
}
